package com.example.dsplatform.utls;

import org.springframework.stereotype.Component;

@Component
public class Dmes {
    public String extractLastCharacter(String mes) {
        if (mes != null && !mes.isEmpty()) {
            int lastIndex = mes.length() - 1;
            char lastCharacter = mes.charAt(lastIndex);
            return String.valueOf(lastCharacter);
        } else {
            // 如果字符串为空或为null，根据需求返回空字符串或其他默认值
            return "";
        }
    }

    public String removeLastCharacter(String mes) {
        if (mes != null && !mes.isEmpty()) {
            return mes.substring(0, mes.length() - 1);
        } else {
            // 如果字符串为空或为null，根据需求返回空字符串或其他默认值
            return "";
        }
    }
}
